package com.ynny.chapter05_06.serlver;

import com.ynny.chapter05_06.bean.Score;
import com.ynny.chapter05_06.bean.Course;
import com.ynny.chapter05_06.bean.Xk;
import com.ynny.chapter05_06.dao.CourseMage;
import com.ynny.chapter05_06.dao.ScoreManage;
import com.ynny.chapter05_06.dao.XkMage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;



@Controller("LgoinImpl")
public class LgoinImpl implements Ilgoin{
    @Autowired
    CourseMage courseMage;
    @Autowired
    ScoreManage scoreManage;
    @Autowired
    XkMage xkMage;
    @Override
    public Boolean login(String number, String password) {
        if(number.equals("11015")&&password.equals("654321")){
            System.out.println("教师登录成功");
            System.out.println("查询所有成绩记录");
            scoreManage.selectAllScore();
            for (Score scores :scoreManage.selectAllScore()) {
                System.out.println(scores);
            }
            System.out.println("更新20220102001的数学成绩");
            scoreManage.updateScore("20220102001","数学",99.0);
            System.out.println(scoreManage.selectAllScore());




        } else if (number.equals("20220102001")&&password.equals("123456")) {
            System.out.println("学生登录成功");
            System.out.println("查询20220102001的成绩记录");
            Score scores = scoreManage.selectScore("20220102001");
            System.out.println(scores);
            System.out.println("查询待选课记录");
            courseMage.selectAllCourse();
            for (Course conurses : courseMage.selectAllCourse()) {
                System.out.println(conurses);
            }
            System.out.println("更新的选课记录");
            courseMage.updateCourse(1,2,1);
            xkMage.updateXk("20220102001",1);
            System.out.println("查询20220102001的选课记录");
            Xk xk =xkMage.selectXk("20220102001");
            System.out.println(xk);



        }
        return true;
    }
}